<!--头部公共部分-->
{include file="common/header" /}
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a>首页</a>
        <a>财务</a>
        <a>
          <cite>报读项目</cite></a>
      </span>
    <a class="layui-btn layui-btn-xs layui-btn-small" style="float:right;margin-top: 10px;"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon layui-icon-refresh"></i> </a>
</div>
<div class="layui-tab layui-tab-brief" lay-filter="filter">
    <ul class="layui-tab-title">
        <li class="layui-this">报读课程</li>
        <li>报读班级</li>
        <li>购买物品</li>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <div class="layui-row">
                <div class="layui-form layui-col-md12 x-so layui-form-pane" style="margin-left: 20px;">
                    <div class="layui-input-inline">
                        <select name="campus_id" lay-verify="required" lay-search="">
                            <option value="">选择校区</option>
                            {volist name="campus" id="campu"}
                            <option value="{$campu.id}">{$campu.campus_name}</option>
                            {/volist}
                        </select>
                    </div>
                    <div class="layui-input-inline">
                        <select name="course_id" lay-search="">
                            <option value="">报读课程</option>
                            {volist name="course_list" id="vo"}
                            <option value="{$vo.id}">{$vo.course_name}</option>
                            {/volist}
                        </select>
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" name="contract_number" placeholder="订单编号" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" style="width: auto" placeholder="选择签约日期" name="signing_date" id="start">
                    </div>

                    <div class="layui-input-inline">
                        <button class="layui-btn" data-type="reload" id="search_course">筛选</button>
                        <button class="layui-btn layui-btn-danger" id="clear_course">重置</button>
                    </div>
                </div>
            </div>
            <div class="x-body">
                <table class="layui-table" id="datalist_course" lay-filter="Event"></table>
            </div>
        </div>
        <div class="layui-tab-item">
            <div class="layui-row">
                <div class="layui-form layui-col-md12 x-so layui-form-pane" style="margin-left: 20px;">
                    <div class="layui-input-inline">
                        <select name="campus_id_grades" lay-verify="required" lay-search="">
                            <option value="">选择校区</option>
                            {volist name="campus" id="campu"}
                            <option value="{$campu.id}">{$campu.campus_name}</option>
                            {/volist}
                        </select>
                    </div>
                    <div class="layui-input-inline">
                        <select name="grades_name" lay-search="">
                            <option value="">报读班级</option>
                            {volist name="grades_list" id="vo"}
                            <option value="{$vo.id}">{$vo.grades_name}</option>
                            {/volist}
                        </select>
                    </div>
                    <div class="layui-input-inline">
                        <select name="course_id_grades" lay-search="">
                            <option value="">报读课程</option>
                            {volist name="course_list" id="vo"}
                            <option value="{$vo.id}">{$vo.course_name}</option>
                            {/volist}
                        </select>
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" name="contract_number_grades" placeholder="订单编号" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" style="width: auto" placeholder="选择签约日期" name="signing_date_grades" id="start_grades">
                    </div>

                    <div class="layui-input-inline">
                        <button class="layui-btn" data-type="reload" id="search_grades">筛选</button>
                        <button class="layui-btn layui-btn-danger" id="clear_grades">重置</button>
                    </div>
                </div>
            </div>
            <div class="x-body">
                <table class="layui-table" id="datalist_grades" lay-filter="Event"></table>
            </div>
        </div>
        <div class="layui-tab-item">
            <div class="layui-row">
                <div class="layui-form layui-col-md12 x-so layui-form-pane" style="margin-left: 20px;">
                    <div class="layui-input-inline">
                        <select name="campus_id_goods" lay-verify="required" lay-search="">
                            <option value="">选择校区</option>
                            {volist name="campus" id="campu"}
                            <option value="{$campu.id}">{$campu.campus_name}</option>
                            {/volist}
                        </select>
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" name="contract_number_goods" placeholder="订单编号" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" style="width: auto" placeholder="选择签约日期" name="signing_date_goods" id="start_goods">
                    </div>

                    <div class="layui-input-inline">
                        <button class="layui-btn" data-type="reload" id="search_goods">筛选</button>
                        <button class="layui-btn layui-btn-danger" id="clear_goods">重置</button>
                    </div>
                </div>
            </div>
            <div class="x-body">
                <table class="layui-table" id="datalist_goods" lay-filter="Event"></table>
            </div>
        </div>
    </div>
</div>

<!--底部公共部分-->
{include file="common/footer" /}
<script>
    layui.use(['table', 'element', 'laydate', 'layer'], function () {
        var table = layui.table,
            laydate = layui.laydate,
            element = layui.element,
            layer = layui.layer,
            $ = layui.$;

        element.on('tab(filter)', function(data){
            console.log(this); //当前Tab标题所在的原始DOM元素
            console.log(data.index); //得到当前Tab的所在下标
            console.log(data.elem); //得到当前的Tab大容器

            if(data.index === 1){   //课程
                tableIns_course.reload();
            }else if(data.index === 2){  //班级

            }else if(data.index === 3){   //物品

            }


        })

        laydate.render({
            elem: '#searchday', //指定元素
            range: true,
            trigger: 'click',
            value: '',
            // btns: ['now', 'confirm'],
            ready: function(date) {
                //得到初始的日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
            },
            done: function(value, date, endDate) {
            }
        });
        //日期
        laydate.render({
            elem: '#start',
            range: true
            ,trigger: 'click'
        });

        //日期
        laydate.render({
            elem: '#start_grades',
            range: true
            ,trigger: 'click'
        });

        //日期
        laydate.render({
            elem: '#start_goods',
            range: true
            ,trigger: 'click'
        });

        //方法级渲染
        var tableIns_course = table.render({
            elem: '#datalist_course',
            url: '{:url("finance/already_reported_course")}?record_status=' + 1,
            method: 'POST',
            cols: [[
                {field: 'student_name', title: '学员姓名', width: 100, align: 'center'},
                {field: 'course', title: '课程名称',style:'font-weight: bold;', minWidth: 300, align: 'center'},
                {field: 'contract_number', title: '订单编号', width: 200, align: 'center'},
                {field: 'campus', title: '校区', width: 170, align: 'center'},
                {field: 'contract_type', title: '订单类型', width: 100, align: 'center'},
                {field: 'input_type_text', title: '录入类型', width: 100, align: 'center'},
                {field: 'signing_date', title: '签约日期', width: 110, align: 'center'},
                {field: 'total_amount', title: '总金额', width: 100, align: 'center'},
                {field: 'status_course_text', title: '状态', width: 150, align: 'center'},
            ]],
            page: true,
            height: 'full-230',
            done: function (res, curr, count) {
                //如果是异步请求数据方式，res即为你接口返回的信息。
                //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
            }
        });

        //搜索项
        $('#search_course').click(function () {
            var field = {};
            field.contract_number = $('input[name=contract_number]').val();
            field.campus_id = $('select[name=campus_id] option:selected').val();
            field.course_id = $('select[name=course_id]').val();
            var create_date_rang = $('input[name=signing_date]').val();
            if(create_date_rang.length > 0){
                strs_date=create_date_rang.split("-"); //字符分割
                field.start_date = strs_date[0]+'-'+strs_date[1]+'-'+strs_date[2];
                field.end_date = strs_date[3]+'-'+strs_date[4]+'-'+strs_date[5];
            }
            console.log(field);
            tableIns_course.reload({
                where: field,
                method: 'POST',
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });
        //清除
        $('#clear_course').click(function () {
            $('.layui-form-pane').find('.layui-input-inline').each(function (index, element) {
                $(element).find('input[type=text]').val('');
                $(element).find('select').val('');
            })
            tableIns_course.reload({
                where: {
                    'contract_number': '',
                    'course_id': '',
                    'campus_id':'',
                    'signing_date':''
                },
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });


        //方法级渲染
        var tableIns_grades = table.render({
            elem: '#datalist_grades',
            url: '{:url("finance/already_reported_course")}?record_status=' + 2,
            method: 'POST',
            cols: [[
                {field: 'student_name', title: '学员姓名', width: 100, align: 'center'},
                {field: 'grades_name', title: '班级名称',style:'font-weight: bold;', minWidth: 200, align: 'center'},
                {field: 'course', title: '课程名称',style:'font-weight: bold;', minWidth: 300, align: 'center'},
                {field: 'contract_number', title: '订单编号', width: 200, align: 'center'},
                {field: 'campus', title: '校区', width: 170, align: 'center'},
                {field: 'contract_type', title: '签约类型', width: 100, align: 'center'},
                {field: 'input_type_text', title: '录入类型', width: 100, align: 'center'},
                {field: 'signing_date', title: '签约日期', width: 110, align: 'center'},
                {field: 'total_amount', title: '总金额', width: 100, align: 'center'},
                {field: 'status_course_text', title: '状态', width: 150, align: 'center'},
            ]],
            page: true,
            height: 'full-230',
            done: function (res, curr, count) {
                //如果是异步请求数据方式，res即为你接口返回的信息。
                //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
            }
        });

        //搜索项
        $('#search_grades').click(function () {
            var field = {};
            field.contract_number = $('input[name=contract_number_grades] option:selected').val();
            field.campus_id = $('select[name=campus_id_grades] option:selected').val();
            field.course_id = $('select[name=course_id_grades] option:selected').val();
            field.grades_id = $('select[name=grades_name] option:selected').val();
            var create_date_rang = $('input[name=signing_date_grades]').val();
            if(create_date_rang.length > 0){
                strs_date=create_date_rang.split("-"); //字符分割
                field.start_date = strs_date[0]+'-'+strs_date[1]+'-'+strs_date[2];
                field.end_date = strs_date[3]+'-'+strs_date[4]+'-'+strs_date[5];
            }
            console.log(field);
            tableIns_grades.reload({
                where: field,
                method: 'POST',
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });
        //清除
        $('#clear_grades').click(function () {
            $('.layui-form-pane').find('.layui-input-inline').each(function (index, element) {
                $(element).find('input[type=text]').val('');
                $(element).find('select').val('');
            })
            tableIns_grades.reload({
                where: {
                    'contract_number_grades': '',
                    'course_id_grades': '',
                    'campus_id_grades':'',
                    'signing_date_grades':'',
                    'grades_id':''
                },
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });


        //方法级渲染
        var tableIns_goods = table.render({
            elem: '#datalist_goods',
            url: '{:url("finance/already_reported_course")}?type=' + 1,
            method: 'POST',
            loading: true ,
            parseData: function (res) { //res 即为原始返回的数据
            if (res.code === 1) {
                res.code = 0;
            } else {
                res.code = -1;
            }
            return {
                "code": res.code, //解析接口状态
                "msg": res.message, //解析提示文本
                "count": res.data.total, //解析数据长度
                "data": res.data.data //解析数据列表
            };
        },
            cols: [[
                {field: 'student_name', title: '学员姓名', width: 100, align: 'center'},
                {field: 'goods_name', title: '物品名称', width: 100, align: 'center'},
                {field: 'type_text', title: '类型',style:'font-weight: bold;', minWidth: 200, align: 'center'},
                {field: 'contract_number', title: '订单编号', width: 200, align: 'center'},
                {field: 'unit', title: '单位',style:'font-weight: bold;', minWidth:100, align: 'center'},
                {field: 'nums', title: '数量', width: 100, align: 'center'},
                {field: 'campus', title: '校区', width: 170, align: 'center'},
                {field: 'contract_type', title: '签约类型', width: 100, align: 'center'},
                {field: 'input_type_text', title: '录入类型', width: 100, align: 'center'},
                {field: 'signing_date', title: '签约日期', width: 110, align: 'center'},
                {field: 'total_amount', title: '总金额', width: 100, align: 'center'},
                {field: 'status_course_text', title: '状态', width: 150, align: 'center'},
            ]],
            page: true,
            height: 'full-230',
            done: function (res, curr, count) {
                //如果是异步请求数据方式，res即为你接口返回的信息。
                //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
            }
        });

        //搜索项
        $('#search_goods').click(function () {
            var field = {};
            field.contract_number = $('input[name=contract_number_goods]').val();
            field.campus_id = $('select[name=campus_id_goods] option:selected').val();
            var create_date_rang = $('input[name=signing_date_goods]').val();
            if(create_date_rang.length > 0){
                strs_date=create_date_rang.split("-"); //字符分割
                field.start_date = strs_date[0]+'-'+strs_date[1]+'-'+strs_date[2];
                field.end_date = strs_date[3]+'-'+strs_date[4]+'-'+strs_date[5];
            }
            console.log(field);
            tableIns_goods.reload({
                where: field,
                method: 'POST',
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });
        //清除
        $('#clear_goods').click(function () {
            $('.layui-form-pane').find('.layui-input-inline').each(function (index, element) {
                $(element).find('input[type=text]').val('');
                $(element).find('select').val('');
            })
            tableIns_goods.reload({
                where: {
                    'contract_number_goods': '',
                    'campus_id_goods':'',
                    'signing_date_goods':''
                },
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });
    });
</script>
<script>var _hmt = _hmt || [];
(function () {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
